% TEST_ID: LANG-EXPAND-0081
% CATEGORY: stdlib/arithmetic_ops/bitops
% 测试 bitshift 函数
function test_bit_bitshift()
r = bitshift(4, 2);
assert(isequal(r, 16));
assert(isa(r, 'double'));
r = bitshift(4, -2);
assert(isequal(r, 1));
assert(isa(r, 'double'));
r = bitshift(4, 2, 'int32');
assert(isequal(r, 16));
assert(isa(r, 'double'));
r = bitshift(4, -2, 'int16');
assert(isa(r, 'double'));
assert(isequal(r, 1));
r = bitshift(4, 0);
assert(isequal(r, 4));
r = bitshift(int8(4), 2);
assert(isequal(r, 16));
assert(isa(r, 'int8'));
r = bitshift(int8(3), 7);
assert(isequal(r, -128));
assert(isa(r, 'int8'));
r = bitshift(int8(3), 6);
assert(isequal(r, -64));
assert(isa(r, 'int8'));

assert(bitshift(6,5:7,'uint8') == [192  128  0])
assert(bitshift(-6,5:7,'int8') == [64  -128  0])
assert(bitshift(2,1) == 4);

assert(bitshift(-127, -2, 'int8') == -32)
assert(bitshift(3,-4,'int16') == 0)

assert(bitshift(intmax('int16'), 3) == -8)
assert(bitshift(intmax('int16'), -3) == 4095)

assert(bitshift(int8(-128), 4) == 0)
assert(bitshift(int8(-128), -4) == -8)